package 笔试.爱笔;

import java.sql.Time;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author:谢君臣
 * @Date:2021/10/16-9:43
 * @version:1.0
 * @function:
 */
public class Main {
    public static void main(String[] args) {
        System.out.println(generateParenthesis(3));
    }
    public static int generateParenthesis(int n) {
        // write code here
        if (n==0) return n;
        ArrayList<Object> list = new ArrayList<>();
        dfs("",0,0,n,list);
        return list.size();
    }
    private static void dfs(String s, int l,int r, int n, ArrayList<Object> objects) {
        if (l==n&&r==n){
            objects.add(s);
        }
        if (l<r){return;}
        if (l<n) dfs(s +"(", l+1, r, n, objects);
        if (r<n) dfs(s+")", l, r+1, n, objects);
    }

    public int maxPoints (Point[] points) {
        // write code here
        if(points.length<3) return points.length;
        int res = 0;
        int a = points.length>>1;
        for (int i = 0; i < points.length; i++) {
            Point m = points[i];
            for (int j = i+1; j < points.length; j++) {
                int c = 2;
                int dx = points[j].x-m.x;
                int dy = points[j].y-m.y;
                int d = dx*m.y-dy*m.x;
                for (int k = j+1; k < points.length; k++) {
                    if (dx*points[k].y ==dy*points[k].x + d) {
                        c++;
                    }
                }
                if (c>a) return c;
                if (c>res) res = c;
            }
        }
        return res;
    }
    public class Point {
      int x;
      int y;
      public Point(int x, int y) {
        this.x = x;
        this.y = y;
      }
    }

}
